﻿#ifndef MYCUSTOMPLOT_H
#define MYCUSTOMPLOT_H

#include <QObject>
#include "qcustomplot.h"

#define FIREDATALEN (3)

class MyCustomPlot : public QCustomPlot
{
    Q_OBJECT
public:
    explicit MyCustomPlot(QWidget *parent = nullptr);
    virtual ~MyCustomPlot();

    void demoTest();
    void init();
    void clear();
    void showAllGraph();

    void ClrFireData();
    void SaveFireData(uint8_t, double);
    void showFireGraph();

protected:
    virtual void keyPressEvent(QKeyEvent *e);
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseMoveEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);

    virtual bool eventFilter(QObject *watched, QEvent *event);

private:
    QCPGraph* chromeGraph;
    QCPGraph* voltGraph;

    //Rect zoom
    QRubberBand *rbRect;
    QPoint rbStartPos;
    bool rbCancel;

    QVector<double> fireData[FIREDATALEN];
    QCPGraph* fireGraph[FIREDATALEN];
};

#endif // MYCUSTOMPLOT_H
